package com.yyz.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

public class HibernateUtils {
    private static Configuration configuration=null;
    private static SessionFactory sessionFactory=null;

    static{
        try {
            configuration=new Configuration().configure();
            sessionFactory=configuration.buildSessionFactory();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    public static SessionFactory getSessionFactory(){
        return sessionFactory;
    }

    public static Session getSession(){
        return sessionFactory.openSession();
    }

    public static void main(String[] args) {

    }

}
